package com.ruoyi.web.controller.admin;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.HospitalSubscribeScheduleCapacity;
import com.ruoyi.system.service.IHospitalSubscribeScheduleCapacityService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 时段余量Controller
 * 
 * @author ruoyi
 * @date 2025-04-28
 */
@RestController
@RequestMapping("/admin/capacity")
public class HospitalSubscribeScheduleCapacityAdminController extends BaseController
{
    @Autowired
    private IHospitalSubscribeScheduleCapacityService hospitalSubscribeScheduleCapacityService;

    /**
     * 查询时段余量列表
     * @response {@link HospitalSubscribeScheduleCapacity}
     */
    @GetMapping("/list")
    public TableDataInfo list(HospitalSubscribeScheduleCapacity hospitalSubscribeScheduleCapacity)
    {
        startPage();
        List<HospitalSubscribeScheduleCapacity> list = hospitalSubscribeScheduleCapacityService.selectHospitalSubscribeScheduleCapacityList(hospitalSubscribeScheduleCapacity);
        return getDataTable(list);
    }

    /**
     * 导出时段余量列表
     */
    @Log(title = "时段余量", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HospitalSubscribeScheduleCapacity hospitalSubscribeScheduleCapacity)
    {
        List<HospitalSubscribeScheduleCapacity> list = hospitalSubscribeScheduleCapacityService.selectHospitalSubscribeScheduleCapacityList(hospitalSubscribeScheduleCapacity);
        ExcelUtil<HospitalSubscribeScheduleCapacity> util = new ExcelUtil<HospitalSubscribeScheduleCapacity>(HospitalSubscribeScheduleCapacity.class);
        util.exportExcel(response, list, "时段余量数据");
    }

    /**
     * 获取时段余量详细信息
     * @response {@link HospitalSubscribeScheduleCapacity}
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(hospitalSubscribeScheduleCapacityService.selectHospitalSubscribeScheduleCapacityById(id));
    }

    /**
     * 新增时段余量
     */
    @Log(title = "时段余量", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HospitalSubscribeScheduleCapacity hospitalSubscribeScheduleCapacity)
    {
        return toAjax(hospitalSubscribeScheduleCapacityService.insertHospitalSubscribeScheduleCapacity(hospitalSubscribeScheduleCapacity));
    }

    /**
     * 修改时段余量
     */
    @Log(title = "时段余量", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HospitalSubscribeScheduleCapacity hospitalSubscribeScheduleCapacity)
    {
        return toAjax(hospitalSubscribeScheduleCapacityService.updateHospitalSubscribeScheduleCapacity(hospitalSubscribeScheduleCapacity));
    }

    /**
     * 删除时段余量
     */
    @Log(title = "时段余量", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(hospitalSubscribeScheduleCapacityService.deleteHospitalSubscribeScheduleCapacityByIds(ids));
    }
}
